// 文件传输相关的类型定义

export interface FileChunk {
  chunkIndex: number;
  chunkOffset: number;
  chunkData: ArrayBuffer;
  chunkMd5: string;
}

export interface ProgressInfo {
  totalBytesWritten: number;
  totalContentLength: number;
  chunkCount: number;
  currentChunkIndex: number;
  currentChunkBytesWritten: number;
  currentChunkContentLength: number;
  progressPercentage: number;
  uploadSpeed?: number; // 上传速度，单位：字节/秒
  remainingTime?: number; // 剩余时间，单位：秒
}

export interface ProgressStatus {
  currentChunkIndex: number;
  totalBytesWritten: number;
  chunkCount: number;
  totalContentLength: number;
  workingChunkBytesWritten: number;
  workingChunkSize: number;
}

export interface UploadFileInfo {
  fileName: string;
  totalSize: number;
}

export interface ChunkInfo {
  chunkIndex: number;
  chunkMD5: string;
  chunkOffset: number;
}

export type ChunkProgressHandler = (progressInfo: ProgressInfo) => void;
export type ProgressListenerDelegate = (
  bytesWritten: number,
  contentLength: number,
) => void;

// MD5计算进度回调
export type Md5ProgressHandler = (
  processedBytes: number,
  totalBytes: number,
  percentage: number,
) => void;

export interface FileUploadOptions {
  chunkSize?: number;
  maxRetry?: number;
  onProgress?: ChunkProgressHandler;
  onMd5Progress?: Md5ProgressHandler; // 添加MD5计算进度回调
}
